import request from '@/utils/request';
const api_name = '/house';

export default {
  // 通过id获取房源
  getHouseById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'get'
    });
  },
  // 根据条件查询房源(分页)
  getHouseListByPage(page, limit, searchObj) {
    return request({
      url: `${api_name}/${page}/${limit}`,
      method: 'post',
      data: searchObj
    });
  },
  // 根据ID删除一个房源
  removeHouseById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'delete'
    });
  },
  // 新增一个房源
  saveHouse(house) {
    return request({
      url: `${api_name}/`,
      method: 'post',
      data: house
    });
  },
  // 修改一个房源
  updateHouse(house) {
    return request({
      url: `${api_name}/${house.houseId}`,
      method: 'put',
      data: house
    });
  }
};
